<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopSearchHistoryTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_search_history', ['comment' => '搜索历史', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('user_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '用户'])
            ->addColumn('keyword', 'string', ['limit' => 255, 'comment' => '关键词'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_search_history');
        $table->drop();
    }
}
